﻿<%@ Page Language="C#" MasterPageFile="~/Web.master" AutoEventWireup="true" CodeBehind="Dict.aspx.cs"
  Inherits="XFSale.Aux.DictPage" %>

<asp:Content ID="partMain" ContentPlaceHolderID="partMain" runat="server">
  <asp:SqlDataSource ID="dsDict" runat="server" ConnectionString="<%$ ConnectionStrings:txfund %>"
    ProviderName="<%$ ConnectionStrings:txfund.ProviderName %>" SelectCommand="select * from XmDict where upper(itemName) like :itemName order by itemOrder, upper(itemName)"
    UpdateCommand="update XmDict set itemType=:itemType, itemScale=:itemScale, itemPrecise=:itemPrecise, itemDesc=:itemDesc, itemVerify=:itemVerify, itemDefault=:itemDefault, itemDetail=:itemDetail, itemOrder=:itemOrder, summary=:summary where itemName=:itemName"
    InsertCommand="insert into XmDict(itemName, itemType, itemScale, itemPrecise, itemDesc, itemVerify, itemDefault, itemDetail, itemOrder, summary) values(:itemName, :itemType, :itemScale, :itemPrecise, :itemDesc, :itemVerify, :itemDefault, :itemDetail, :itemOrder, :summary)"
    DeleteCommand="delete from XmDict where itemName=:itemName"></asp:SqlDataSource>
  <asp:SqlDataSource ID="dsDictTemp" runat="server" ConnectionString="<%$ ConnectionStrings:txfund %>"
    ProviderName="<%$ ConnectionStrings:txfund.ProviderName %>"></asp:SqlDataSource>
  <table runat="server" id="pnlSearch" width="100%" class="search">
    <tr>
      <td>
        数据项名称
        <asp:TextBox runat="server" ID="txtItemName" Columns="20" ValidationGroup="Search" />
        <asp:ImageButton runat="server" ID="btnSearch" ToolTip="检索" ValidationGroup="Search"
          ImageUrl="~/image/icon_funtion.gif" ImageAlign="AbsMiddle" OnClick="btnSearch_Click" />
        <%--
        <asp:RequiredFieldValidator runat="server" ValidationGroup="Search" ControlToValidate="txtItemName" ErrorMessage="请输入检索条件"
          EnableClientScript="true" />
        --%>
      </td>
      <td align="right" valign="middle">
        <asp:ImageButton runat="server" ID="btnInsert" ToolTip="新增" ValidationGroup="Action"
          ImageUrl="~/image/add.png" ImageAlign="AbsMiddle" OnClick="btnInsert_Click" />
      </td>
    </tr>
  </table>
  <asp:GridView ID="gvDict" runat="server" DataSourceID="dsDict" PageSize="15" AllowPaging="True"
    AllowSorting="True" AutoGenerateColumns="False" Width="100%" BackColor="White"
    BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1" CellPadding="3" DataKeyNames="itemName"
    ForeColor="Black" GridLines="None" OnRowCommand="gvDict_RowCommand" OnRowDataBound="gvDict_RowDataBound"
    OnRowDeleted="gvDict_RowDeleted" OnRowDeleting="gvDict_RowDeleting" OnRowUpdated="gvDict_RowUpdated"
    OnRowUpdating="gvDict_RowUpdating" OnRowEditing="gvDict_RowEditing" OnSelectedIndexChanged="gvDict_SelectedIndexChanged"
    OnSelectedIndexChanging="gvDict_SelectedIndexChanging">
    <FooterStyle BackColor="#CCCC99" />
    <RowStyle BackColor="#F7F7DE" />
    <Columns>
      <asp:BoundField DataField="itemName" ReadOnly="True" HeaderText="名称" SortExpression="itemName"
        ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" />
      <asp:BoundField DataField="itemType" HeaderText="类型" ItemStyle-HorizontalAlign="Left"
        HeaderStyle-HorizontalAlign="Left" />
      <asp:BoundField DataField="itemScale" HeaderText="长度" ItemStyle-HorizontalAlign="Left"
        HeaderStyle-HorizontalAlign="Left" />
      <asp:BoundField DataField="itemPrecise" HeaderText="精度" ItemStyle-HorizontalAlign="Left"
        HeaderStyle-HorizontalAlign="Left" />
      <asp:BoundField DataField="itemDesc" HeaderText="描述" ItemStyle-HorizontalAlign="Left"
        HeaderStyle-HorizontalAlign="Left" />
      <asp:BoundField DataField="itemVerify" HeaderText="验证规则" ItemStyle-ForeColor="#444444"
        ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" />
      <asp:BoundField DataField="itemDefault" HeaderText="缺省值" ItemStyle-ForeColor="#444444"
        ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" />
      <asp:BoundField DataField="itemOrder" HeaderText="顺序" ItemStyle-ForeColor="#444444"
        ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" />
      <asp:TemplateField HeaderText="操作">
        <ItemStyle HorizontalAlign="Right" />
        <HeaderStyle HorizontalAlign="Right" />
        <ItemTemplate>
          <asp:ImageButton ID="btnSelect" runat="server" ToolTip="取值" ImageUrl="~/image/gb.gif"
            CommandName="Select" CssClass="button3" />
          <asp:ImageButton ID="btnEdit" runat="server" ToolTip="编辑" ImageUrl="~/image/btn_edit.gif"
            CommandName="Edit" CssClass="button3" />
          <asp:ImageButton ID="btnDelete" runat="server" ToolTip="删除" ImageUrl="~/image/btn_delete2.gif"
            CommandName="Delete" CssClass="button3" OnClientClick="return confirm('确定删除此数据项？');" />
        </ItemTemplate>
      </asp:TemplateField>
    </Columns>
    <PagerSettings Mode="NumericFirstLast" PageButtonCount="10" />
    <PagerStyle Font-Bold="True" HorizontalAlign="Right" CssClass="pager" />
    <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="White" />
  </asp:GridView>
  <asp:FormView ID="fvDict" runat="server" DataSourceID="dsDict" DefaultMode="ReadOnly"
    Width="100%" OnItemInserted="fvDict_ItemInserted" DataKeyNames="itemName" OnItemUpdated="fvDict_ItemUpdated"
    OnItemCommand="fvDict_ItemCommand" OnPreRender="fvDict_PreRender" OnItemInserting="fvDict_ItemInserting"
    OnItemUpdating="fvDict_ItemUpdating">
    <EditItemTemplate>
      <table>
        <tr>
          <td>
            数据项名称：
          </td>
          <td>
            <asp:TextBox ID="txtItemName" runat="server" Text='<%# Bind("itemName") %>' Columns="30" />
            <span class="required">*</span>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="txtItemName" ErrorMessage="数据项名称必须填写"
              EnableClientScript="true" Display="Dynamic" />
            <asp:RegularExpressionValidator runat="server" ControlToValidate="txtItemName" ValidationExpression="^\w{1,30}$"
              ErrorMessage="数据项名称不合法" EnableClientScript="true" Display="Dynamic" />
          </td>
        </tr>
        <tr>
          <td>
            数据项类型：
          </td>
          <td>
            <%--
            <asp:TextBox ID="txtItemType" runat="server" Text='<%# Bind("itemType") %>' Columns="5" />
            <span class="required">*</span>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="txtItemType" ErrorMessage="数据项类型必须填写"
              EnableClientScript="true" Display="Dynamic" />
            <asp:RegularExpressionValidator runat="server" ControlToValidate="txtItemType" ValidationExpression="^[CAN]$"
              ErrorMessage="数据项类型不合法" EnableClientScript="true" Display="Dynamic" />
            --%>
            <asp:DropDownList ID="ddlItemType" runat="server">
              <asp:ListItem Value="C" Text="C - 字符型" />
              <asp:ListItem Value="A" Text="A - 数字型" />
              <asp:ListItem Value="C" Text="N - 数值型" />
            </asp:DropDownList>
            <span class="required">*</span>
          </td>
        </tr>
        <tr>
          <td>
            数据项长度：
          </td>
          <td>
            <asp:TextBox ID="txtItemScale" runat="server" Text='<%# Bind("itemScale") %>' Columns="5" />
            <span class="required">*</span>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="txtItemScale" ErrorMessage="数据项长度必须填写"
              EnableClientScript="true" Display="Dynamic" />
            <asp:RegularExpressionValidator runat="server" ControlToValidate="txtItemScale" ValidationExpression="^\d{1,3}$"
              ErrorMessage="数据项长度不合法" EnableClientScript="true" Display="Dynamic" />
          </td>
        </tr>
        <tr>
          <td>
            数据项精度：
          </td>
          <td>
            <asp:TextBox ID="txtItemPrecise" runat="server" Text='<%# Bind("itemPrecise") %>'
              Columns="5" />
            <span class="required">*</span>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="txtItemPrecise" ErrorMessage="数据项精度必须填写"
              EnableClientScript="true" Display="Dynamic" />
            <asp:RegularExpressionValidator runat="server" ControlToValidate="txtItemPrecise"
              ValidationExpression="^\d{1,3}$" ErrorMessage="数据项精度不合法" EnableClientScript="true"
              Display="Dynamic" />
            <asp:CompareValidator runat="server" ControlToValidate="txtItemPrecise" ControlToCompare="txtItemScale"
              Operator="LessThanEqual" ErrorMessage="数据项精度必须小于等于长度" EnableClientScript="true"
              Display="Dynamic" />
          </td>
        </tr>
        <tr>
          <td>
            数据项描述：
          </td>
          <td>
            <asp:TextBox ID="txtItemDesc" runat="server" Text='<%# Bind("itemDesc") %>' Columns="45" />
            <span class="required">*</span>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="txtItemDesc" ErrorMessage="数据项描述必须填写"
              EnableClientScript="true" Display="Dynamic" />
          </td>
        </tr>
        <tr>
          <td>
            数据项验证规则：
          </td>
          <td>
            <asp:TextBox ID="txtItemVerify" runat="server" Text='<%# Bind("itemVerify") %>' Columns="45" />
          </td>
        </tr>
        <tr>
          <td>
            数据项默认值：
          </td>
          <td>
            <asp:TextBox ID="txtItemDefault" runat="server" Text='<%# Bind("itemDefault") %>'
              Columns="45" />
          </td>
        </tr>
        <tr>
          <td>
            数据项顺序：
          </td>
          <td>
            <asp:TextBox ID="txtItemOrder" runat="server" Text='<%# Bind("itemOrder") %>' Columns="5" />
            <asp:RegularExpressionValidator runat="server" ControlToValidate="txtItemOrder" ValidationExpression="^\d{1,4}$"
              ErrorMessage="数据项顺序不合法" EnableClientScript="true" Display="Dynamic" />
          </td>
        </tr>
        <tr>
          <td>
            允许取值？：
          </td>
          <td>
            <asp:RadioButtonList ID="rblItemDetail" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
              <asp:ListItem Value="N">否</asp:ListItem>
              <asp:ListItem Value="Y">是</asp:ListItem>
            </asp:RadioButtonList>
          </td>
        </tr>
        <tr>
          <td>
            备注：
          </td>
          <td>
            <asp:TextBox ID="txtSummary" runat="server" TextMode="MultiLine" Text='<%# Bind("summary") %>'
              Columns="45" Rows="3" />
          </td>
        </tr>
      </table>
      <asp:Button ID="btnInsert" runat="server" CausesValidation="True" CommandName="Insert"
        Text="新增" CssClass="button" />
      <asp:Button ID="btnUpdate" runat="server" CausesValidation="True" CommandName="Update"
        Text="更新" CssClass="button" />
      <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
        Text="取消" CssClass="button" />
    </EditItemTemplate>
  </asp:FormView>
</asp:Content>
